function back() {
	history.back();
}
var token = sessionStorage.getItem("token");
var appid = sessionStorage.getItem("appid");
var ID = sessionStorage.getItem("postID");
var username = sessionStorage.getItem("username");
var postname = sessionStorage.getItem("postname");
//http://v2.mashupcloud.cn/SQL/add_follow/   添加关注
function ToComment() {
	location.href = "../comment/comment.html"
}
var vue = new Vue({
	el: 'body',
	data: {
		isloading: true,
		detail: {},
		zan: false,
		coll: false,
		info: {},
		isfollow: false,
		isfollowmodel:"关注"
	},
	created: function() {
		var _this = this;
		$.ajax({
			type: 'get',
			url: "http://v2.mashupcloud.cn/SQL/select_userinfo/",
			async: true,
			data: {
				appid: appid,
				token: token,
				name: 'select_userinfo',
				_v1: postname,
			},
			success: function(json) {
				vue.info = JSON.parse(json)[2][0];
				console.log(vue.info);
			},
			error: function(json) {
				console.log("err:" + json);
			}
		});
		$.ajax({
			type: 'get',
			url: 'http://v2.mashupcloud.cn/SQL/get_post_detail/',
			data: {
				appid: appid,
				token: token,
				name: 'get_post_detail',
				_v1: ID, //参数1  _v3,_v4 .......
			},
			success: function(json) {
				console.log("json==" + json);
				vue.detail = JSON.parse(json)[2][0];
				sessionStorage.setItem("postname", _this.detail.username);
				vue.isloading = !vue.isloading;
			},
			error: function(json) {
				console.log("err:" + json);
			}
		});
	},
	methods: {
		addzan: function() {
			if(username == null) {
				location.href = "../load/load.html"
			} else {
				this.zan = !this.zan;
				if(this.zan) { //http://v2.mashupcloud.cn/SQL/addcount/
					this.detail.count = this.detail.count + 1;
					$.ajax({
						type: 'get',
						url: 'http://v2.mashupcloud.cn/SQL/addcount/',
						data: {
							appid: appid,
							token: token,
							name: 'addcount',
							_v1: ID, //参数1  _v3,_v4 .......
						},
						success: function(json) {
							console.log("json==" + json);
						},
						error: function(json) {
							console.log("err:" + json);
						}
					});
				} else { //http://v2.mashupcloud.cn/SQL/delcount/
					this.detail.count = this.detail.count - 1;
					$.ajax({
						type: 'get',
						url: 'http://v2.mashupcloud.cn/SQL/delcount/',
						data: {
							appid: appid,
							token: token,
							name: 'delcount',
							_v1: ID, //参数1  _v3,_v4 .......
						},
						success: function(json) {
							console.log("json==" + json);
						},
						error: function(json) {
							console.log("err:" + json);
						}
					});
				}
			}
		},
		addcoll: function() {
			if(username == null) {
				location.href = "../load/load.html"
			} else {
				this.coll = !this.coll;
				if(this.coll) {
					//http://v2.mashupcloud.cn/SQL/del_collment/
					$.ajax({
						type: 'get',
						url: 'http://v2.mashupcloud.cn/SQL/add_Collection/',
						data: {
							appid: appid,
							token: token,
							name: 'add_Collection',
							_v1: ID, //参数1  _v3,_v4 .......
							_v2: username, //参数1  _v3,_v4 .......
						},
						success: function(json) {
							console.log("json==" + json);
							$.toast("收藏成功", function() {
								console.log('close');
							});
						},
						error: function(json) {
							console.log("err:" + json);
						}
					});
				} else {
					$.ajax({
						type: 'get',
						url: 'http://v2.mashupcloud.cn/SQL/del_Colletion/',
						data: {
							appid: appid,
							token: token,
							name: 'del_Colletion',
							_v1: ID, //参数1  _v3,_v4 .......
							_v2: username, //参数1  _v3,_v4 .......
						},
						success: function(json) {
							console.log("json==" + json);
							$.toast("取消操作", "cancel", function(toast) {
								console.log(toast);
							});
						},
						error: function(json) {
							console.log("err:" + json);
						}
					});
				}
			}
		},
		addfollow: function() {
			//http://v2.mashupcloud.cn/SQL/add_follow/
			//http://v2.mashupcloud.cn/SQL/del_follow/
			this.coll = !this.coll;
			if(this.coll) {
				$.ajax({
					type: 'get',
					url: 'http://v2.mashupcloud.cn/SQL/add_follow/',
					data: {
						appid: appid,
						token: token,
						name: 'add_follow',
						_v1: username, //参数1  _v3,_v4 .......
						_v2: vue.info.username, //参数1  _v3,_v4 .......
					},
					success: function(json) {
						console.log("json==" + json);
						vue.isfollowmodel="已关注";
						vue.isfollow=true;
						$.toast("关注成功", function() {
							console.log('close');
						});
					},
					error: function(json) {
						console.log("err:" + json);
					}
				});
			} else {
				$.ajax({
					type: 'get',
					url: 'http://v2.mashupcloud.cn/SQL/del_follow/',
					data: {
						appid: appid,
						token: token,
						name: 'del_follow',
						_v1: username, //参数1  _v3,_v4 .......
						_v2: vue.info.username, //参数1  _v3,_v4 .......
					},
					success: function(json) {
						console.log("json==" + json);
						vue.isfollowmodel="关注";
						vue.isfollow=false;
						$.toast("操作成功", function() {
							console.log('close');
						});
					},
					error: function(json) {
						console.log("err:" + json);
					}
				});
			}
		}
	}
});